package com.lihua.newideas.controller;

import com.lihua.newideas.pojo.Comment;
import com.lihua.newideas.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class CommentController {

    @Autowired
    CommentService commentService;

    @RequestMapping("/insertComment")
    @ResponseBody
    public String insertComment(Comment comment) {
        System.out.println(comment);
        String s = commentService.insertComment(comment);
        return s;
    }

    @ResponseBody
    @RequestMapping("/admin/deleteComment/{id}")
    public String deleteComment (@PathVariable("id") String id){
        commentService.deleteCommentById(Long.valueOf(id));

        return "删除成功";
    }
}
